
public class Slider {
	
	public float x;
	public float y;
	public float height;
	public float width;
	public float max;
	public float min;
	public float current;
	private float cursorX;
	float currentCursorX = 0;
	
	Slider(float x, float y, float width, float height,float min, float max)
	{
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
		this.max = max;
		this.min = min;
		cursorX = 0;
		current =0;
		cursorX = x+current*(width/max);
	}
	
	void draw()
	{
	      Gui.parent.stroke(Gui.parent.color(200,200,200));	  
	      Gui.parent.fill(Gui.parent.color(240,240,240));	  
		  Gui.parent.rect(x,y,width,height);	
	      Gui.parent.fill(Gui.parent.color(200,200,200));	  
		  Gui.parent.ellipse(currentCursorX+5, y+height/2, 20, 20);
	}
	
	void update()
	{

		if(Gui.parent.mousePressed)
		{
			if(Gui.parent.mouseX>x && Gui.parent.mouseX<x+width &&
			   Gui.parent.mouseY>y && Gui.parent.mouseY<y+height+5)
			{
				current = (int)((Gui.parent.mouseX - x)/(width/max));
				cursorX = x+current*(width/max);
			}
		}
		currentCursorX += (cursorX-currentCursorX)/16;
	}

	public void mouseDragged() {
		// TODO Auto-generated method stub
		if(Gui.parent.mousePressed)
		{
			if(Gui.parent.mouseX>x && Gui.parent.mouseX<x+width &&
			   Gui.parent.mouseY>y && Gui.parent.mouseY<y+height+5)
			{
				current = (int)((Gui.parent.mouseX - x)/(width/max));
				cursorX = x+current*(width/max);
			}
		}
		currentCursorX += (cursorX-currentCursorX)/16;
		
	}
}
